﻿using System;
using UnityEngine;

namespace RootMotion.FinalIK
{
	// Token: 0x0200013D RID: 317
	[Serializable]
	public class ConstraintPositionOffset : Constraint
	{
		// Token: 0x060004C4 RID: 1220 RVA: 0x00014FDD File Offset: 0x000133DD
		public ConstraintPositionOffset()
		{
		}

		// Token: 0x060004C5 RID: 1221 RVA: 0x00014FE5 File Offset: 0x000133E5
		public ConstraintPositionOffset(Transform transform)
		{
			this.transform = transform;
		}

		// Token: 0x060004C6 RID: 1222 RVA: 0x00014FF4 File Offset: 0x000133F4
		public override void UpdateConstraint()
		{
			if (this.weight <= 0f)
			{
				return;
			}
			if (!base.isValid)
			{
				return;
			}
			if (!this.initiated)
			{
				this.defaultLocalPosition = this.transform.localPosition;
				this.lastLocalPosition = this.transform.localPosition;
				this.initiated = true;
			}
			if (this.positionChanged)
			{
				this.defaultLocalPosition = this.transform.localPosition;
			}
			this.transform.localPosition = this.defaultLocalPosition;
			this.transform.position += this.offset * this.weight;
			this.lastLocalPosition = this.transform.localPosition;
		}

		// Token: 0x17000030 RID: 48
		// (get) Token: 0x060004C7 RID: 1223 RVA: 0x000150B7 File Offset: 0x000134B7
		private bool positionChanged
		{
			get
			{
				return this.transform.localPosition != this.lastLocalPosition;
			}
		}

		// Token: 0x04000207 RID: 519
		public Vector3 offset;

		// Token: 0x04000208 RID: 520
		private Vector3 defaultLocalPosition;

		// Token: 0x04000209 RID: 521
		private Vector3 lastLocalPosition;

		// Token: 0x0400020A RID: 522
		private bool initiated;
	}
}
